package com.ximu.oss.controller;

import com.ximu.common_utils.Result;
import com.ximu.oss.service.OssService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;


/**
 * @projectName: guli
 * @package: com.ximu.oss.controller
 * @className: OssController
 * @author: ximu
 * @description: TODO
 * @date: 2022/4/2 11:06
 * @version: 1.0
 */

@Api(tags = "上传")
@RestController
@RequestMapping("dev-api/eduoss")
@CrossOrigin
public class OssController {

    @Autowired
    private OssService ossService;

    @ApiOperation(value = "头像上传")
    @PostMapping("file")
    public Result uploadOssFile(
            @ApiParam(name = "file",value = "选择文件",required = true)
            @RequestParam(value="file",required=true)
            MultipartFile file){
        //MulticastChannel :获取上传文件
        String upload = ossService.upload(file);
        return Result.ok().message("头像上传成功").data("url",upload);
    }

}
